#include "commuart.h"

CommUart::CommUart()
{
}

CommUart::~CommUart()
{
}

void CommUart::Config(IF_SOC_Uart *uart, IProtocol *protocol)
{
    if(uart == nullptr || protocol == nullptr)
        return;
    
    m_uart = uart;
    m_uart->SetDataReceivedCallBack([=](auto &sender, auto b){
        RecvByte(b);
    });
    
    ConfigBase(protocol);
}

void CommUart::OnWriteStream(uint8_t *data, int len)
{
    if(m_uart == nullptr)
        return;
    
    m_uart->Write(data, len);
}
